/**
 * IndexTopicDtoTransformer.java
 */
package com.mht2017.common.dto.transformer;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.mht2017.common.dto.IndexTopicDto;
import org.apache.commons.collections.CollectionUtils;


/**
 * @author yutong.xiao
 * @date 2017年5月16日 上午9:14:46
 */
public class IndexTopicDtoTransformer {

	public static List<String> pickTopics(Collection<IndexTopicDto> indics) {
		Set<String> allTopics = new HashSet<>();
		if (CollectionUtils.isNotEmpty(indics)) {
			for (IndexTopicDto indexTopicDto : indics) {
				if (CollectionUtils.isNotEmpty(indexTopicDto.getTopics())) {
					allTopics.addAll(indexTopicDto.getTopics());
				}
			}
		}
		return new ArrayList<>(allTopics);
	}

	public static List<String> pickTables(Collection<IndexTopicDto> indics) {
		Set<String> allTables = new HashSet<>();
		if (CollectionUtils.isNotEmpty(indics)) {
			for (IndexTopicDto indexTopicDto : indics) {
				if (CollectionUtils.isNotEmpty(indexTopicDto.getTables())) {
					allTables.addAll(indexTopicDto.getTables());
				}
			}
		}
		return new ArrayList<>(allTables);
	}

}
